﻿// See https://aka.ms/new-console-template for more information

namespace 第三次作业
{
    static class Constants
    {
        public const double Pi = 3.14;

        public abstract class shape
        {
            
            int x;
            int y;
            public abstract double getArea();
            public abstract bool ShapeisLegal();
        }

        public class Rectangle : shape
        {
            int x;
            int y;
            public Rectangle(int x, int y)
            {
                this.x = x;
                this.y = y;
            }

            public override double getArea()
            {
                return x * y;
            }
            public override bool ShapeisLegal()
            {
                if (x != 0 && y != 0) return true;
                else return false;
            }
        }
        public class Square : shape
        {
            int x;
            int y;
            public Square(int x, int y)
            {
                this.x = x;
                this.y = y;
            }

            public override double getArea()
            {
                if (x == y)
                    return x * y;
                else return 0;
            }
            public override bool ShapeisLegal()
            {
                if (x == y) return true;
                else return false;
            }
        }
        public class Circle : shape
        {
            int x;
            int y;
            public Circle(int x, int y)
            {
                this.x = x;
                this.y = y;
            }

            public override double getArea()
            {
                if (x == y) 
                return x * x * Pi;
                else return 0;
            }
            public override bool ShapeisLegal()
            {
                if (x == y) return true;
                else return false;
            }
        }
        class progam
        {

            static void Main(string[] args)
            {
                shape Circle1=new Circle(1,1);
                shape Circle2=new Circle(2,2);
                shape Circle3=new Circle(3,3);
                shape Suqare1=new Square(4,4);
                shape Suqare2 = new Square(4, 4);
                shape Suqare3 = new Square(4, 4);
                shape Suqare4 = new Square(4, 4);
                shape Rectangle1 = new Rectangle(1, 2);
                shape Rectangle2 = new Rectangle(1, 6);
                shape Rectangle3 = new Rectangle(5, 2);
                shape Rectangle4 = new Rectangle(16, 2);
                Console.WriteLine( Circle1.getArea());

            }
        }
    }
}